<template>
  <el-form-item label="区域:" prop="serviceRegion">
    <regionCustom :value.sync="model.serviceRegion" code="421200" :show-all-levels="true" />
  </el-form-item>
</template>

<script>
import regionCustom from '@/components/xm/region/regionCustom'
export default {
  components: {
    regionCustom
  },
  data() {
    return {
    }
  },
  mounted() {},
  methods: {
    edit(rowData) {
      this.model = JSON.parse(JSON.stringify(rowData))
      if (rowData.area && rowData.street && rowData.community) {
        this.$set(this.model, 'serviceRegion', [rowData.area, rowData.street, rowData.community])
      } else if (rowData.area && rowData.street) {
        this.$set(this.model, 'serviceRegion', [rowData.area, rowData.street])
      } else if (rowData.area) {
        this.$set(this.model, 'serviceRegion', [rowData.area])
      }
      this.model.serviceRegion.unshift('421200') // ['421200', '421221', '4212210005']
      console.log('完整地区编码', this.model.serviceRegion)
      /*
      需要注意 地区编码需要对应数据源，比如数据源根code是421200 ， 没有给上的话无法回显
      */
    },
    searchRegionChange(e) {
      const path = e[0].path
      if (path && path.length) {
        this.model.area = path[1]
        this.model.street = path[2]
        this.model.community = path[3]
      }
      console.log('this.model', this.model)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
